package com.example.redis.web;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RedisController {

       @Autowired
    private RedisTemplate redisTemplate;

    @RequestMapping("/set")
    public String set(String name) {
        redisTemplate.opsForValue().set("name", name);
        return name;
    }

    @RequestMapping("/get")
    public Object get(String key) {
        Object obj = redisTemplate.opsForValue().get(key);
        return obj;
    }

}
